package co.edu.usbcali.csru.modelo.dto;

import co.edu.usbcali.csru.modelo.TipoPersona;
import co.edu.usbcali.csru.presentation.backingBeans.TipoPersonaView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class TipoPersonaDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String tipNombreP;
    private String tipCodigoP;
    private boolean rowSelected = false;
    private TipoPersonaView tipoPersonaView;
    private TipoPersona tipoPersona;

    public TipoPersona getTipoPersona() {
        return tipoPersona;
    }

    public String listener_update(ActionEvent e) {
        try {
            tipoPersonaView.action_modifyWitDTO(((tipCodigoP == null) ||
                tipCodigoP.equals("")) ? null : new String(tipCodigoP),
                ((tipNombreP == null) || tipNombreP.equals("")) ? null
                                                                : new String(
                    tipNombreP));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        tipCodigoP = tipoPersona.getTipCodigoP().toString();
        tipNombreP = (tipoPersona.getTipNombreP() != null)
            ? tipoPersona.getTipNombreP().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        tipCodigoP = tipoPersona.getTipCodigoP().toString();
        tipNombreP = (tipoPersona.getTipNombreP() != null)
            ? tipoPersona.getTipNombreP().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setTipoPersona(TipoPersona tipoPersona) {
        this.tipoPersona = tipoPersona;
    }

    public TipoPersonaView getTipoPersonaView() {
        return tipoPersonaView;
    }

    public void setTipoPersonaView(TipoPersonaView tipoPersonaView) {
        this.tipoPersonaView = tipoPersonaView;
    }

    public String getTipNombreP() {
        return tipNombreP;
    }

    public void setTipNombreP(String tipNombreP) {
        this.tipNombreP = tipNombreP;
    }

    public String getTipCodigoP() {
        return tipCodigoP;
    }

    public void setTipCodigoP(String tipCodigoP) {
        this.tipCodigoP = tipCodigoP;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
